= stylesheet_link_tag "chat"
#main
#users
%p{:style=>"clear:both; padding-top:10px;"}
%form{:id=>'form', :onsubmit=>'return broadcast();'}
  ข้อความ:
  = text_field_tag "msg", nil, :size=>"50"
  = hidden_field_tag "login", @login
  = hidden_field_tag "embed", params[:embed]
  = submit_tag "ส่งข้อความ"

#last{:style=>'display:none;'}= @chat ? @chat.id : 0
#num_users{:style=>'display:none;'} 0

%script
  function update() {
  $.getScript('/chat/update/'+$('#last').text()+'?num_users='+$('#num_users').text());
  };

  function broadcast() {
  var msg= encodeURIComponent($('#msg').val())
  //alert('msg='+msg);
  $.get('/chat/broadcast?msg='+msg)
  $('#msg').val("");
  $('#msg').focus();
  return false;
  };

  function f() {
  return false;
  }

%script
  $(function() {
  setInterval("update()", 3000);
  })
